home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / vernon.zip / SINOFX.PAS < prev    next >
Pascal/Delphi Source File  |  1989-07-23  |  1KB  |  57 lines

  1.  
  2. program SINOFX;
  3.  
  4.    {I+}
  5.   { This program calculates sin(x) using the Taylor's series
  6.     expansion:
  7.                                  i      (2i + 1)
  8.               sin(x)  =      (-1)      x
  9.                              ---------------
  10.                                (2i + 1) !
  11.  
  12.      by continuing to calculate a new term until the value has
  13.      been calculated to within an accuracy of .0001             }
  14.  
  15. uses crt;
  16.  
  17.    var  x :real;  I, Q : integer;  Sum, Y : real; TERM1 : real;
  18.  
  19.   {$I Power.pas }
  20.   {$I Neg1.pas }
  21.   {$I Xval.pas }
  22.   {$I Fact.pas }
  23.   {$I Term.pas }
  24.  
  25.     begin
  26.  
  27.         ClrScr;
  28.  
  29.        HighVideo;
  30.  
  31.         TextColor(12);
  32.  
  33.         write('Enter a value in degrees for x to find the value sin(x): ');
  34.         readln (x);
  35.  
  36.         Q := trunc(X / 360);
  37.         x := x - Q * 360;
  38.         x := x * pi /180;
  39.         sum := 0;
  40.         I := 0;
  41.  
  42.        { while x <> 0 do begin} if x = 0 then sum := 0 else
  43.         while  ABS (term(x,i)) > 0.0001 do begin
  44.           Sum := Sum + Term(X,I);
  45.           term1 := term(x,i);
  46.           {WRITELN('The value of term is: ', TERM1);}
  47.           I := I + 1
  48.           end; {while accuracy}
  49.         {  end; while x }
  50.         writeln;
  51.         writeln('Sin(x) = ', Sum:12:4);
  52.         LowVideo;
  53.  
  54.  end.
  55.  
  56.  
  57.